package com.serverTechnology.teamsGroups.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import com.serverTechnology.teamsGroups.entity.dto.*;
import com.serverTechnology.teamsGroups.entity.vo.DeviceTreeVo;
import com.serverTechnology.teamsGroups.service.ProModelService;
import com.serverTechnology.teamsGroups.entity.vo.ProModelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;

@RestController
@ApiResource(name = "产线模型的接口")
@Api(tags = "产线管理")
public class ProModelController {

    @Resource(name="ProModelServiceImpl")
    private ProModelService proModelService;

    /**
     * 添加产线模型
     * @param proModel
     * @return
     */
    @PostResource(name = "添加产线模型", path = "/proModel/add")
    @ApiOperation(value = "添加产线模型")
    public ResponseData add(@RequestBody @Validated ProModelAddDto proModel) {
        proModelService.add(proModel);
        return new SuccessResponseData<>();
    }

    /**
     * 查询产线模型详情
     * @param id
     * @return
     */
    @GetResource(name = "查询产线模型详情", path = "/proModel/sel")
    @ApiOperation(value = "查询产线模型详情")
    public ResponseData sel(Long id) {
        return new SuccessResponseData<>(proModelService.sel(id));
    }

    /**
     * 修改产线模型
     * @param proModel
     * @return
     */
    @PostResource(name="修改产线模型", path = "/proModel/edit")
    @ApiOperation(value = "修改产线模型")
    public ResponseData edit(@RequestBody @Validated ProModelEditDto proModel) {
        proModelService.edit(proModel);
        return new SuccessResponseData<>();
    }

    /**
     * 删除产线模型
     * @param id
     * @return
     */
    @PostResource(name = "删除产线模型", path = "/proModel/del")
    @ApiOperation(value = "删除产线模型")
    public ResponseData del(Long id) {
        proModelService.del(id);
        return new SuccessResponseData<>();
    }

    /**
     * 查询产线模型列表
     * @param proModel
     * @return
     */
    @GetResource(name = "查询产线模型列表", path = "/proModel/page")
    @ApiOperation(value = "查询产线模型列表")
    public ResponseData<List<ProModelVo>> pages(ProModelDto proModel) {
        return new SuccessResponseData<>(proModelService.pages(proModel));
    }


    @PostResource(name = "添加设备工具配置", path = "/proModel/save")
    @ApiOperation(value = "添加设备工具配置")
    public ResponseData saves(@RequestBody @Validated ProDeviceToolUserAddDto proModel) {
        proModelService.saves(proModel);
        return new SuccessResponseData<>();
    }
    @ApiModelProperty(value ="选择设备菜单树")
    @PostMapping("/proModel/getDeviceTree")
    @ApiOperation(value = "选择设备菜单树")
    public List<DeviceTreeVo> getDeviceTree() {
        return proModelService.getDeviceTree();
    }
    @ApiModelProperty(value ="选择工具菜单树")
    @PostMapping("/proModel/getToolTree")
    public List<DeviceTreeVo> getToolTree() {
        return proModelService.getToolTree();
    }

    /**
     *
     *查询产线模型设备工具配置列表
     * @param proModelTool
     * @return
     */
    @GetResource(name = "查询产线模型设备工具配置列表", path = "/proModel/pageDevice")
    @ApiOperation(value = "查询产线模型设备工具配置列表")
    public ResponseData<List<ProModelVo>> pageDevice(ProDeviceToolUserSeleDeviceDto proModelTool) {
        return new SuccessResponseData<>(proModelService.pageDevice(proModelTool));
    }



}
